#include <dbnc_flt.h>

bool dbnc_flt::poll(unsigned int tick, bool in) {
    if (flg) {
        if (in) {
            tim_off = tick;
        } else {
            if ((tick - tim_off) > thr_off) {
                // logger.info("low tick=%d", Rtos::ticks());
                flg = false;
                tim_on = tick;
            }
        }
    } else {
        if (in) {
            if ((tick - tim_on) > thr_on) {
                // logger.info("high tick=%d", Rtos::ticks());
                flg = true;
                tim_off = tick;
            }
        } else {
            tim_on = tick;
        }
    }
    return flg;
}
